﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.Common;
using System.Reflection;

namespace CH.Study.ConsoleApp.ExpressionTree
{
    public class QueryEnumerable<T> : IEnumerable<T>, IEnumerable
    {
        QueryEnumerator<T> enumerator;


        public QueryEnumerable(DbDataReader reader)
        {
            this.enumerator = new QueryEnumerator<T>(reader);
        }


        public IEnumerator<T> GetEnumerator()
        {
            QueryEnumerator<T> e = this.enumerator;
            if (e == null)
            {
                throw new InvalidOperationException("没有可用的枚举器");
            }
            this.enumerator = null;
            return e;
        }


        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }



    }


}
